<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : listManager.xsl
    Created on : November 19, 2013, 9:18 AM
    Author     : Liem
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:p="http://xml.netbeans.org/schema/account" exclude-result-prefixes="p"
version="1.0">
    <xsl:output method="html"/>
    <xsl:param name="pageId"></xsl:param>
    <xsl:param name="username"></xsl:param>
    <!-- TODO customize transformation rules 
         syntax recommendation http://www.w3.org/TR/xslt 
    -->
    <xsl:template match="/">
        <xsl:if test="//*[p:username=$username and p:pageId=$pageId and p:role='owner']">
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-head blue">
                    <h3 class="page-header">Add manager to this page</h3>
                </div>
                <div class="profile-info">
                    <form action="addUserToPage.action" class="form-inline">
                        <input type="hidden" name="pageId">
                            <xsl:attribute name="value">
                                <xsl:value-of select="$pageId"/>
                            </xsl:attribute>
                        </input>
                        <label class="control-label">Username:</label>
                        <input type="text" name="username"/>
                        <button type="submit" class="btn btn-success">Add</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="row-fluid">
            <div class="span12">
                <table border="2" class="table responsive">
                    <tr>
                        <th>Username</th>
                        <th>Remove</th>
                    </tr>
                    <xsl:for-each select="//*[p:pageId=$pageId and p:role='manager']">
                        <tr>
                            <td>
                                <xsl:value-of select="p:username"/>
                            </td>
                            <td>
                                <a href="#" class="btn">
                                    <xsl:attribute name="href">removeUserToPage.action?username=<xsl:value-of select="p:username"/>&amp;pageId=<xsl:value-of select="$pageId"/>
                                    </xsl:attribute>
                                    <i class=" icon-remove"></i>Remove
                                </a>
                            </td>
                        </tr>
                    </xsl:for-each>
                </table>
            </div>
        </div>
        </xsl:if>
    </xsl:template>

</xsl:stylesheet>
